package com.yc.system.controller;

import java.util.List;

import com.yc.system.dto.ChangeOrder;
import com.yc.system.dto.OrderDto;
import com.yc.system.entity.BookCartLike;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import  com.yc.system.service.IBookOrderService;


import com.yc.framework.baseClass.BaseController;
//import com.yc.framework.baseClass.ServiceFacade;
import com.yc.framework.baseClass.R;
import com.yc.system.entity.BookOrder;
/**
 * <p>
    * 订单交易 前端控制器
    * </p>
 *
 * @author 1850140986@qq.com
 * @since 2022-12-06
 */
@RestController
@RequestMapping("/sys/bookOrder")
public class BookOrderController extends BaseController
    {

    @Autowired
        //private IBookOrderService t_book_orderService;
  private IBookOrderService service;

  /**
   * 根据条件分页查询BookOrder
   * @param model 实体对象
   * @return 查询列表
   */
     @PostMapping("/list")
    public R list(@RequestBody BookOrder model){
        return service.list(model);

    }

    /**
    * 根据主键查询单个对象
    * @param model 实体对象包含uuid
    * @return 成功或失败
    */
    @GetMapping("/getById/{id}")
    public R getById(@PathVariable String id) {
        return service.getModelById(id);
    }

    /**
	 * 新增实体对象
	 *
     * @param model 实体对象
	 * @return 新增是否成功
	 */
     @PostMapping("/save")
	public R save(@RequestBody BookOrder model) {
		return service.saveModel(model);

	}

    /**
	 * 批量新增实体对象
	 *
     * @param modelList 实体对象列表
	 * @return 新增是否成功
	 */
	@PostMapping("/saveBatch")
	public R saveBatch(@RequestBody List<BookOrder> modelList) {
		return service.saveModelBatch(modelList);

	}

    /**
	 * 根据主键删除实体
	 *
     * @param uuid 实体携带主键
	 * @return 删除是否成功
	 */
	@DeleteMapping("/removeById/{id}")
	public R removeById(@PathVariable String id) {
		return service.removeModelById(id);
	}

     /**
	 * 根据主键列表删除实体
	 *
     * @param idList 实体主键
	 * @return 删除是否成功

	@DeleteMapping("/removeByIdList")
	public R removeByIdList(@RequestBody List<BookOrder> idList) {
        return service.removeModelByIdList(idList);

    }
 */
    /**
    * 根据主键修改实体
    *
    * @param model 等待修改的对象
    * @return 修改是否成功
    */
    @PutMapping("/updateById")
    public R updateModelById(@RequestBody BookOrder model) {
        return service.updateModelById(model);

    }

    /**
    * 根据主键列表修改实体列表
    *
    * @param modelList 等待修改的对象列表
    * @return 修改是否成功
    */
    @PostMapping("/updateByIdBatch")
    public R updateModelByIdBatch(@RequestBody List<BookOrder> modelList) {
        return service.updateModelByIdBatch(modelList);

    }

      /**
	 * 根据多主键列表删除实体
	 *
     * @param idList 多主键
	 * @return 删除是否成功
	 */
	@DeleteMapping("/removeByIds/{ids}")
	public R removeByIdList(@PathVariable String ids) {
        return service.removeModelByIds(ids);

    }

    @GetMapping("/getOrderListByUserId")
	public R getOrderListByUserId(@RequestParam("userId") int userId) {
		return service.getOrderListByUserId(userId);

	}

	@GetMapping("/getOrderListByIssuerId")
	public R getOrderListByIssuerId(@RequestParam("issuerId") int ssuerId) {
		return service.getOrderListByIssuerId(ssuerId);
	}

	@PostMapping("/add")
	public R addOrder(@RequestBody BookOrder bookOrder){
		return service.addOrder(bookOrder);
	}


	@PostMapping("/updata")
	public R updataOrder(@RequestBody BookOrder bookOrder){
			return service.updataOrder(bookOrder);
	}

	@PostMapping("/getOrderListByPageUserId")
	public R getOrderListByPageUserId(@RequestBody OrderDto findByPage) {
//		return service.getOrderListByPageUserId(findByPage);
		return service.getOrders(findByPage);
	}

	@PostMapping("/changeOrderStatus")
	public R changeOrderStatus(@RequestBody OrderDto orderDto) {
		return service.changeOrderStatus(orderDto);
	}

	@PostMapping("byCart")
	public R addOrdersByCart(@RequestBody List<BookCartLike> orderDto) {
		return service.addOrdersByCart(orderDto);
	}

		@PostMapping("changeOrder")
		public R changeOrder(@RequestBody ChangeOrder changeOrder) {
			return service.changeOrder(changeOrder);
		}

		@GetMapping("getissuerInfo")
		public R getissuerInfoByOrderId(@RequestParam("orderId") int orderId) {
			return service.getissuerInfoByOrderId(orderId);
		}

		@GetMapping("getCustomerInfo")
		public R getCustomerInfoByOrderId(@RequestParam("orderId") int orderId) {
			return service.getCustomerInfoByOrderId(orderId);
		}


}
